import 'dart:async';

import 'package:flutter/material.dart';
import '../../helper/Helper.dart';
import '../../helper/cacheHelper.dart';
import '../../model/inspectreport.dart';
import '../../widgets/IconWidget.dart';
import '../../widgets/dialogWidget.dart';
import '../../widgets/inputWidget.dart';

import '../../model/user.dart';

class InspectCard {
  static Widget inspectButton(BuildContext context, String text,
      String tooltips, VoidCallback onPressed,
      {double mt1 = 40}) {
    return Container(
        margin: EdgeInsets.only(top: mt1, bottom: 10.0),
        child: Center(
            child: SizedBox(
                width: 150.0,
                height: 150.0,
                child: FloatingActionButton(
                    child: Text(
                      text,
                      style: TextStyle(fontSize: 16.0),
                    ),
                    onPressed: () {
                      DialogWidget.ShowUpload(context, tooltips, onPressed);
                    }))));
  }

  static List<Widget> getWidgetList(BuildContext context, InspectReport x1) {
    List<Widget> list1 = <Widget>[];
    List<Widget> list2 = <Widget>[];
    List<Widget> list3 = <Widget>[];
    List<Widget> list4 = <Widget>[];
    List<Widget> list5 = <Widget>[];
    List<Widget> list6 = <Widget>[];
    list1.add(InputWidget.inCard(
      ListTile(
        leading: IconWidget.InspectReportImage(),
        title: Text(
          Helper.DateTimeFormat(x1.CreateTM),
        ),
        subtitle: Text(x1.Members),
      ),
    ));

    var showColor1 = Colors.blue;

    var v1 = InputWidget.getShowInfo("巡查区域", x1.Zone, showColor1);
    var v2 = InputWidget.getShowInfo("巡查类型", x1.InspectType, showColor1);
    var v3 =
        InputWidget.getShowInfo("巡查里程", "${x1.Distance.toInt()} 米", showColor1);
    var v4 =
        InputWidget.getShowInfo("巡查耗时", "${x1.MinutesLast} 分钟", showColor1);
    list4.add(InputWidget.getShowRow([v1, v2], true));
    list4.add(InputWidget.getDivider());
    list4.add(InputWidget.getShowRow([v3, v4], true));
    // list4.add(InputWidget.getInfo("巡查人员", x1.Members));

    var f1 = InputWidget.getShowInfo("船只", x1.Wt1, showColor1);
    var f2 = InputWidget.getShowInfo("码头", x1.Wt2, showColor1);
    var f3 = InputWidget.getShowInfo("非法行为", x1.Wt3, showColor1);
    var f4 = InputWidget.getShowInfo("库岸边坡", x1.Wt4, showColor1);
    var f5 = InputWidget.getShowInfo("库区漂浮物", x1.Wt5, showColor1);
    var f6 = InputWidget.getShowInfo("库区水质", x1.Wt6, showColor1);
    list3.add(InputWidget.getShowRow([f1, f2], true));
    list3.add(InputWidget.getDivider());
    list3.add(InputWidget.getShowRow([f3, f4], true));
    list3.add(InputWidget.getDivider());
    list3.add(InputWidget.getShowRow([f5, f6], true));

    list5.add(InputWidget.getInfo2("其他异常及处置", x1.Wt7));

    list1.add(InputWidget.inCard2(list4));
    list1.add(InputWidget.inCard2(list3));
    list1.add(InputWidget.inCard2(list5));

    list1.add(Container(
      height: 56.0,
      child: Text(""),
    ));

    return list1;
  }

  static Widget BodyHeader(BuildContext context, InspectReport X1) {
    return Column(children: getWidgetList(context, X1));
    User u1 = CacheHelper.GetUser(X1.UserId);

    return Card(
      child: Column(children: <Widget>[
        ListTile(
          title: Text("巡查范围"),
          trailing: Text(X1.InspectType),
        ),
        Divider(
          height: 0.0,
        ),
        ListTile(
          title: Text("巡查人员"),
          trailing: Text(X1.InspectType),
        ),
        Divider(
          height: 0.0,
        ),
        ListTile(
          title: Text("开始时间"),
          trailing: Text(X1.CreateTM),
        ),
        Divider(
          height: 0.0,
        ),
        ListTile(
          title: Text("巡查时间"),
          trailing: Text("${X1.MinutesLast} 分钟"),
        ),
        Divider(
          height: 0.0,
        ),
        ListTile(
          title: Text("巡查里程"),
          trailing: Text("${X1.Distance.toInt()} 米"),
        ),
      ]),
      //color: GlobalConfig.cardBackgroundColor,
      margin: const EdgeInsets.all(6.0),
    );
  }

  static List<Widget> BodyReport(InspectReport X1) {
    return <Widget>[
      ListTile(
        title: Text("河道保洁河道养护工作是否到位"),
        trailing: X1.Wt1 == true ? Text("是") : Text("否"),
      ),
      Divider(
        height: 0.0,
      ),
      ListTile(
        title: Text("工业企业是否有偷拍漏排、超标排放等环境违法行为"),
        trailing: X1.Wt2 == true ? Text("是") : Text("否"),
      ),
      Divider(
        height: 0.0,
      ),
      ListTile(
        title: Text("河岸是否存在各类涉水违法建筑物"),
        trailing: X1.Wt3 == true ? Text("是") : Text("否"),
      ),
      Divider(
        height: 0.0,
      ),
      ListTile(
        title: Text("是否存在河岸垃圾、泥浆渣土等入水现象"),
        trailing: X1.Wt4 == true ? Text("是") : Text("否"),
      ),
      Divider(
        height: 0.0,
      ),
      ListTile(
        title: Text("河道水质是否有异常变化"),
        trailing: X1.Wt5 == true ? Text("是") : Text("否"),
      ),
      Divider(
        height: 0.0,
      ),
      ListTile(
        title: Text("其他问题"),
        subtitle: Text((X1.Bz1 == null ? "" : X1.Bz1)),
      ),
    ];
  }
}
